home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0031_Direct output to SB Card.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  3KB  |  115 lines

  1. {
  2. NORBERT IGL
  3.  
  4. >> if you already have the DAC Programming, simply Write out each
  5. >> Byte to the DAC PORT (Write $10, then the data For Direct Mode)
  6. >> Then Delay after each Byte, depending on the Sampling rate.
  7. >> You'll have to play around With the Delay's.
  8.  
  9.   Just found a piece of source in my Files.... (:-)),
  10.   but i don't know the original author ( RedFox ? )
  11.   and i translated the (orig.) german remarks....
  12. }
  13.  
  14. Uses
  15.   Crt;
  16. Const
  17.   ResetPort  = $226;
  18.   ReadPort   = $22A;
  19.   WritePort  = $22C;
  20.   StatusPort = $22C;
  21.   DataDaPort = $22E;
  22.  
  23.   { N.I.: Note: Use SB_Port (prev. Msg) to get the correct address.... }
  24.  
  25.   AD_Null       = $80;
  26.   OK            = 0000;
  27.   NichtGefunden = 1000;
  28.   DirectDAC     = $10;
  29.   SpeakerOn     = $D1;
  30.   SpeakerOff    = $D3;
  31.  
  32. Var
  33.   DSPResult   : Word;
  34.   DSPReadWert : Byte;
  35.  
  36.   loop : Word;
  37.   w    : Word;
  38.   m    : Word;
  39.  
  40.  
  41. Procedure WriteToDSP(Command : Byte);
  42. begin
  43.   Repeat Until (port[StatusPort] and $80) = 0;
  44.   port[WritePort] := Command;
  45. end;
  46.  
  47. Procedure ReadFromDSP;
  48. begin
  49.   Repeat Until (port[DataDaPort] and $80) = $80;
  50.   DSPReadWert := port[ReadPort];
  51. end;
  52.  
  53. Procedure ResetDSP;
  54. Var
  55.   MaxVersuch : Byte;
  56. begin
  57.   MaxVersuch:=100;
  58.   Repeat
  59.     port[ResetPort] := 1;
  60.     Delay(10);
  61.     port[ResetPort] := 0;
  62.     ReadFromDSP;
  63.     dec(MaxVersuch);
  64.   Until (DSPReadWert = $AA) or (MaxVersuch = 0);
  65.  
  66.   if MaxVersuch = 0 then
  67.     DSPResult := NichtGefunden
  68.   else
  69.     DSPResult := OK;
  70. end;
  71.  
  72.  
  73. begin
  74.   ClrScr;
  75.  
  76.   ResetDSP;
  77.  
  78.   if DSPResult <> OK then
  79.   begin
  80.     Writeln(' Soundeblaster not found !');
  81.     Writeln(' Wrong SB-address ?');
  82.   end
  83.   else
  84.   begin
  85.     Writeln(' Demo : direct output to the SoundblasterCard !');
  86.     Writeln('  ┌──┐  ┌──┐  ┌──┐  ┌──┐  ┌──┐  ┌  creates a square');
  87.     Writeln('  │  │  │  │  │  │  │  │  │  │  │  waveform With an');
  88.     Writeln('──┘  └──┘  └──┘  └──┘  └──┘  └──┘  64`er amplitude ');
  89.     Writeln;
  90.     Writeln(' RedFox (14.11.91) ');
  91.  
  92.     WriteToDSP(SpeakerOn);               { Speaker on }
  93.  
  94.     m := 5000;                           { dynamc Wait (Init) }
  95.  
  96.     For loop := 1 to 600 do              { 600 samples }
  97.     begin
  98.       dec(m, 10);
  99.       if m < 20 then
  100.         m := 500;
  101.       WriteToDSP(DirectDAC);             { command to SB  }
  102.       WriteToDSP(AD_Null + 32);          { now the sample }
  103.  
  104.       { rising edge    }
  105.       For w := 1 to m do begin end;      { dynamc wait    }
  106.  
  107.       WriteToDSP(DirectDAC);             { command to SB  }
  108.       WriteToDSP(AD_Null - 32);          { falling edge   }
  109.  
  110.       For w := 1 to m do begin end;      { wait again     }
  111.     end;
  112.     WriteToDSP(SpeakerOff);              { speaker off }
  113.   end;
  114. end.
  115.